package com.student.management.root.utils;

import java.util.List;
import java.util.Objects;

public class PageUtil {
    //1.页码值 2.显示条数 3.查询结果列表 4，总条数  5.总页数
    private Integer pageIndex;
    private Integer pageSize=5;
    private List dataList;
    private Integer total;
    private Integer totalPages;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof PageUtil)) return false;
        PageUtil pageUtil = (PageUtil) o;
        return Objects.equals(getPageIndex(), pageUtil.getPageIndex()) &&
                Objects.equals(getPageSize(), pageUtil.getPageSize()) &&
                Objects.equals(getDataList(), pageUtil.getDataList()) &&
                Objects.equals(getTotal(), pageUtil.getTotal()) &&
                Objects.equals(getTotalPages(), pageUtil.getTotalPages());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getPageIndex(), getPageSize(), getDataList(), getTotal(), getTotalPages());
    }

    @Override
    public String toString() {
        return "PageUtil{" +
                "pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", dataList=" + dataList +
                ", total=" + total +
                ", totalPages=" + totalPages +
                '}';
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List getDataList() {
        return dataList;
    }

    public void setDataList(List dataList) {
        this.dataList = dataList;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getTotalPages() {
        return total%pageSize>0?total/pageSize+1:total/pageSize;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public PageUtil() {
    }

    public PageUtil(Integer pageIndex, Integer pageSize, List dataList, Integer total, Integer totalPages) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.dataList = dataList;
        this.total = total;
        this.totalPages = totalPages;
    }
}
